<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>爱贝儿医</title>
	<link rel="stylesheet" href="business/style/common.css?<?=time()?>">
	<link rel="stylesheet" href="business/style/vote/style/vote3.css?<?=time()?>">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
	<script src="app/js/common.js"></script>
	<script src="business/js/jquery.js"></script>
	<script src="//res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
</head>
<body>

	<!-- 头部开始 -->
	<header>
		<img src="business/style/vote/style/headerback1.png" alt="">
	</header>
	<!-- 头部结束 -->
	<!-- 内容区开始 -->
	<div id="content">
		<input type="hidden" id="user_state" value="<?=$user_state?>">
		<input type="hidden" class="db_id" value="<?=$dc_detail->data['id']?>">
		<input type="hidden" class="BiId_all" value="<?=$Bd_id?>"/>
		<input type="hidden" class="voteId_all" value="<?=$vote_re_id?>"/>
		<?php if(isset($_GET['id'])):?>
		<div class="realcon1 person">
			<div class="voteNum"><i><span class="voteNums<?=$dc_detail->data['id']?>"><?=$dc_detail->data['vote_num']?></span></i></div>
			<div class="personInfo clearfix">
				<div class="avatar">
					<img src="<?=G_SITE_CDN?>/<?=$dc_detail->data['head_img']?>" alt="">
				</div>
				<div class="info">
					<h1><?=$dc_detail->data['name']?></h1>
					<p><?=$dc_detail->data['zhicheng']?></p>
					<p><?=$dc_detail->data['hospital']?> <span><?=$dc_detail->data['kehsi']?></span></p>
				</div>
			</div>
			<div class="btn goVote aVote aVoteState<?=$dc_detail->data['id']?>"  onclick="vote(<?=$dc_detail->data['id']?>)">给TA投票</div>
			<!-- 投票的人      -->
			<!--<div class="votePerson">
				<ul>

					<?php foreach($dc_detail->data['voteUsers'] as $ky =>$vy):?>
					<li>
						<img src="<?=$vy['vote_img']?>" alt="">
						<p><?=$vy['vote_name']?><br>
							<?php if($vy['nums']>1):?>
							<i class="votePNum">x<i><?=$vy['nums']?></i></i>
							<?php endif; ?>
						</p>
					</li>
					<?php endforeach;?>
				</ul>
				<div class="downBtn"><img src="business/style/vote/style/down.png" alt=""></div>
			</div>-->
		</div>
		<!-- 他的故事 -->
		<div class="realcon1 story">
			<div class="storyT">TA的故事</div>
			<div class="votePerson1">
				<div class="storyCon">
					<?=$this->preg_img_cdn($dc_detail->data['descript_story'])?>
				</div>
				<div class="downBtn"><img src="business/style/vote/style/down.png" alt=""></div>
			</div>
		</div>
		<!-- 他的故事 -->

		<!-- 二维码 -->
		<div class="realcon1 ewm">
			<div class="ewmImg"><img src="business/style/vote/style/ewm.png" alt=""></div>
			<p>识别上方二维码关注爱贝儿医</p>
			<div class="ewmAd"><img src="business/style/vote/style/ewmAd.png" alt=""></div>
		</div>
		<!-- 二维码 -->
		<?php endif;?>

		<a href="<?=$vote_act?>" class="arule">活动规则</a>
		<a href="<?=$vote_recommend_url?>" class="joinIn">报名参与<span></span></a>
	</div>
	<!-- 内容区结束 -->
	<!-- 弹出层开始 -->
	<div class="layer" >
		<div>
			<h6>认证医生才可以为TA投票哦~</h6>
			<a href="<?=$user_url?>">立即认证</a>

			<p>医生/护士/医学生均可验证</p>
		</div>
	</div>

	<!-- 弹出层结束 -->
	<!-- 尾部开始 -->
	<?php require 'app/templates/common/download.html'; ?>
	<!-- 尾部结束 -->
</body>
<?php require 'app/templates/common/foot.html'; ?>
</html>


<script>
	$('.layer').height($(window).height());

	// 弹出层消失
	$('.layer').click(function() {
		$('.layer').css('display','none');
	});
	$('.layer>div').click(function() {
		event.stopPropagation();
	});

	$(function(){
		var user_state = $("#user_state").val();
		/*页面加载判断投票按钮状态--start*/
		//当前医生id
		var bd_id = $('.db_id').val();
		//将所有用户id -装换为数组类型

		//投票记录表中医生id的数据
		var re_bd_id = $(".voteId_all").val().split("-");

			for(var i in re_bd_id){
				var  a = parseInt(re_bd_id[i]) ;
				if(a==bd_id){
					if(user_state=='已认证'){
						$(".aVoteState"+a).text("已投票");
						$(".aVoteState"+a).addClass('div_color');
					}else{
						$(".aVoteState"+a).text("认证通过后自动投票");
						$(".aVoteState"+a).addClass('div_color');
					}

				}
			}


		/*页面加载判断投票按钮状态--end*/

	});

	function vote(id){
		var user_state = $("#user_state").val();
		if(user_state == '注册' || user_state == '认证'){
			$('.layer').css('display','block');
		}else{
			var useState = 2;
			if(user_state =='认证中'){
				useState = 1;
			}

			var data = {'id':id,'userState':useState};
			var res = common.post('vote','ajax_vote_new',data);
			if(res.message=='已经投过票'){
				common.showMsgBox('您已经给他投过票了！');
			}else if(res.message=='投票失败'){
				common.showMsgBox('投票失败！');
			}
			if(res.result==0){
				if(user_state=="认证中"){
					$(".aVoteState"+id).text("认证通过后自动投票");
					$(".aVoteState"+id).addClass('div_color');

					common.showMsgBox('认证成功后即可显示您的投票信息 : )');
				}else{
					$(".aVoteState"+id).text("已投票");
					$(".aVoteState"+id).addClass('div_color');

					$(".voteNums"+id).text(res.message);
					common.showMsgBox('感谢您的投票，期待您明天继续参与！');

				}
			}

		}

	}

</script>
<script>
	// 拉开收起
	$('.downBtn img').eq(0).click(function(){
		if($(this).attr('src')=="business/style/vote/style/down.png"){
			$(this).attr('src','business/style/vote/style/up.png');
			$(this).parent().parent(".votePerson1").css("height","auto")
		}else{
			$(this).attr('src','business/style/vote/style/down.png')
			$(this).parent().parent(".votePerson1").css("height","11rem")
		}
	});
	// 拉开收起
	wx.config({
		debug: false,
		appId: '<?php echo $this->signPackage["appId"];?>',
		timestamp: '<?php echo $this->signPackage["timestamp"];?>',
		nonceStr: '<?php echo $this->signPackage["nonceStr"];?>',
		signature: '<?php echo $this->signPackage["signature"];?>',
		jsApiList: [
			'onMenuShareAppMessage',
			'onMenuShareTimeline',
			'onMenuShareQQ',
			'onMenuShareWeibo',
			'onMenuShareQZone'
		]
	});

	title = '寻找最美儿科医生——第二阶段医生投票火热启动！';
	desc = '关注“爱贝儿医公众号/最美儿医”发现您身边最真实的感动';
	links = '';
	imgUrl = '<?=G_SITE_CDN?>/<?=$dc_detail->data['head_img']?>';
	weixinShare(title, desc, links, imgUrl);
</script>